<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/static/layuiadmin/layui/css/layui.css" media="all">
</head>
<style>
    input:disabled {
        background: #e8e8e8;
    }
</style>
<body>
<div class="layui-form" lay-filter="layuiadmin-app-form-list" id="layuiadmin-app-form-list">
    <input type="hidden" name="id" value="{$id}">
    <table class="layui-table">
        <tbody>
        <tr>
            <td>收货人信息</td>
            <td>{$address.username}<br>{$address.address}<br>{$address.phone}</td>
        </tr>
        <tr>
            <td>快递公司</td>
            <td>
                <div style="width: 50%;">
                    <select name="shipment" lay-verify="required">
                        <option value="">请选择快递公司</option>
                        <option value="顺丰速运">顺丰速运</option>
                        <option value="圆通速递">圆通速递</option>
                        <option value="中通速递">中通速递</option>
                        <option value="EMS">EMS</option>
                        <option value="韵达快运">韵达快运</option>
                        <option value="百世汇通">百世汇通</option>
                        <option value="申通E物流">申通E物流</option>
                        <option value="天天快递">天天快递</option>
                        <option value="全峰快递">全峰快递</option>
                        <option value="四川快捷">四川快捷</option>
                        <option value="德邦物流">德邦物流</option>
                        <option value="同城配送">同城配送</option>
                        <option value="安能物流">安能物流</option>
                        <option value="邮政小包">邮政小包</option>
                        <option value="特急送">特急送</option>
                        <option value="其它快递">其它快递</option>
                    </select>
                </div>
            </td>
        </tr>
        <tr>
            <td>快递单号</td>
            <td>
                <div style="width: 50%;">
                    <input type="text" name="order_number" lay-verify="required" class="layui-input">
                </div>
            </td>
        </tr>
        <tr>
            <td>备注信息</td>
            <td>
                <textarea name="remark" placeholder="请输入200个字符以内 (可以不填)" class="layui-textarea"></textarea>
            </td>
        </tr>
        </tbody>
    </table>
    <div class="layui-form-item layui-hide">
        <input type="button" lay-submit lay-filter="layuiadmin-app-form-submit" id="layuiadmin-app-form-submit" value="确认添加">
    </div>
</div>
<script src="/static/layuiadmin/layui/layui.js"></script>
<script>
    layui.config({
        base: '/static/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'form'], function(){
        var $ = layui.$,
                form = layui.form;

        //监听提交
        form.on('submit(layuiadmin-app-form-submit)', function(data){
            var field = data.field; //获取提交的字段
            var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
            //提交 Ajax 成功后，关闭当前弹层并重载表格
            $.ajax({
                type: "POST",
                url: "{:url('Product/order_delivery')}",
                data: {field:field},
                dataType: "json",
                success: function(e){
                    if (e == 1){
                        layer.msg('发货成功', {offset: ['30%', '40%']});
                        setTimeout(function () {
                            parent.location.reload(); //重载表格
                            parent.layer.close(index); //再执行关闭
                        }, 500)
                    }else{
                        layer.msg('发货失败', {offset: ['30%', '40%']});
                    }
                }
            });
        });
    })
</script>
</body>
</html>